$OpenBSD: patch-switchuser_cpp,v 1.5 2013/04/18 12:00:45 gonzalo Exp $
add missing setusercontext/setsid/setlogin calls.
--- switchuser.cpp.orig	Mon Dec 31 10:03:42 2012
+++ switchuser.cpp	Wed Apr 17 13:10:36 2013
@@ -10,6 +10,10 @@
 */
 
 #include <cstdio>
+#ifdef __OpenBSD__
+#include <sys/types.h>
+#include <login_cap.h>
+#endif
 #include "switchuser.h"
 #include "util.h"
 
@@ -36,6 +40,9 @@ void SwitchUser::Login(const char* cmd, const char* mc
 
 void SwitchUser::SetUserId() {
 	if( (Pw == 0) ||
+			(setusercontext(NULL, Pw, Pw->pw_uid, LOGIN_SETPRIORITY|LOGIN_SETRESOURCES) == -1) ||
+			(setsid() == -1) ||
+			(setlogin(Pw->pw_name) != 0) ||
 			(initgroups(Pw->pw_name, Pw->pw_gid) != 0) ||
 			(setgid(Pw->pw_gid) != 0) ||
 			(setuid(Pw->pw_uid) != 0) ) {
